package com.xunfang.cloud.controller;

import com.xunfang.cloud.common.api.PayFeignApi;
import com.xunfang.cloud.common.enties.Pay;
import com.xunfang.cloud.common.enties.PayDTO;
import com.xunfang.cloud.common.result.ResultData;
import org.springdoc.core.service.RequestBodyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

/**
 * @author yellow Doctor
 * @date 2025-11-03
 * @desc https://blog.csdn.net/hekai7217
 */
@RestController
public class OrderController {

    @Autowired
    private PayFeignApi payFeignApi;

    @PostMapping("/consumer/pay/add")
    public ResultData addOrder(@RequestBody Pay pay){

        //第三方结构调用
        String result = payFeignApi.addPay(pay);
        return ResultData.success(result);
    }


    // 删除+修改操作作为家庭作业，O(∩_∩)O。。。。。。。
    @GetMapping("/consumer/pay/get/{id}")
    public ResultData getPayInfo(@PathVariable("id") Integer id){
        Pay pay = payFeignApi.getPayInfo(id);
       return ResultData.success(pay);
    }


    @DeleteMapping("/consumer/pay/get/{id}")
    public ResultData deletePayById(@PathVariable("id") Integer id){
        Integer i = payFeignApi.deletePay(id);
        return ResultData.success("删除了" + i + "条记录");
    }

    @GetMapping("/consumer/lb")
    public String getLb(){
        return payFeignApi.getLb();
    }

}
